<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="sysDefault"
	content="text/html; charset=utf-8" />
<link
	href="${staticPath}/lib/datetimepicker/0.0.11/css/bootstrap-datetimepicker.min.css"
	rel="stylesheet" type="text/css">
<link href="${staticPath}/lib/chosen/1.1.0/chosen.min.css"
	rel="stylesheet" type="text/css">
<link rel="stylesheet"
	href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js"
	type="text/javascript"></script>
<script src="${staticPath}/js/jquery-dialog.js" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(function (){
		$("#savebtn").click(function(){	
			if($("#linkName").val()==null||$("#linkName").val()==''){
				alert('请填写链接名称');
				return false;
			}
			else if($("#url").val()==null||$("#url").val()==''){
				alert('请填写链接地址');
				return false;
			}
			else if($("#orderNo").val()==null||$("#orderNo").val()==''){
				alert('请填写排序编号');
				return false;
			}
			
			if(isNaN($("#orderNo").val())){
				alert('请输入正确排序号');
				$("#orderNo").val('');
				return false;
			}
			return true;
		});
	});
	
	function checkOrderNo(orderNo) {
		$.get("${contextPath}/sys/base/link/checkOrderNo?orderNo="
				+ orderNo + "", function(data) {
			var text = eval("(" + data + ")");
			if (text.orderNo == '1') {
				alert("排序号已经存在");
				$('#orderNo').val('');
			}
		});
	}
</script>

</head>
<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-xs-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">
							新增常用资料数据 <a class="btn btn-default btn-sm pull-right" role="button"
								href="javascript:void(0)" onclick="history.go(-1)">返回</a>
						</h3>
					</div>
					<div class="panel-body">
						<div class="col-xs-10">
							<!--<div class="panel-body">-->
							<form:form id="cityForm" modelAttribute="sysBaseLink"
								action="${contextPath}/sys/base/link/saveLink"
								method="post" class="form-horizontal" role="form">
								<form:hidden path="id" />
								<div class="form-group">
									<div class="col-sm-6">
											<label for="linkName" class="col-sm-4 control-label">链接名称</label>
											<div class="col-sm-8">
												<form:input id="linkName" path="linkName" htmlEscape="false"
													class="form-control required"/>
											</div>
									</div>
									
									<div class="col-sm-6">
										<label for="url" class="col-sm-4 control-label">链接地址:</label>
										<div class="col-sm-8">
											<form:input id="url" path="url" htmlEscape="false"
												class="form-control required" />
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-6">
											<label for="orderNo" class="col-sm-4 control-label">排序编号</label>
											<div class="col-sm-8">
												<form:input id="orderNo" path="orderNo" htmlEscape="false"
													class="form-control required" onchange="return checkOrderNo(this.value)"/>
											</div>
									</div>
									<div class="col-sm-6">
											<label for="remark" class="col-sm-4 control-label">详细描述</label>
											<div class="col-sm-8">
												<form:input id="remark" path="remark" htmlEscape="false"
													class="form-control required"/>
											</div>
									</div>
								</div>
								
					
									<div class="form-group">
										<div class="col-sm-offset-6 col-sm-10">
											<input class="btn btn-primary" type="submit" id="savebtn" value="保 存" />
										</div>
									</div>
							</form:form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>